import numpy as np

def generate_c_array_txt():
    total_count = 7916
    
    # 生成随机数
    range1 = np.random.uniform(-4000, -2000, total_count // 2).astype(np.float32)
    range2 = np.random.uniform(3000, 5000, total_count - total_count // 2).astype(np.float32)
    all_numbers = np.concatenate([range1, range2])
    np.random.shuffle(all_numbers)
    
    # 生成 C 数组格式内容
    txt_content = "// ARM64 单精度浮点数组 - 3958 个元素\n"
    txt_content += "// 范围: [-4000, -2000] 和 [3000, 5000]\n"
    txt_content += "static const float float_data[7916] = {\n"
    
    # 每行放置 8 个数值
    for i in range(0, total_count, 8):
        line = "    "
        for j in range(8):
            if i + j < total_count:
                line += f"{all_numbers[i+j]:.6f}f"
                if i + j < total_count - 1:
                    line += ", "
        txt_content += line + "\n"
    
    txt_content += "};"
    
    # 保存为 TXT 文件
    with open("float_array.txt", "w") as f:
        f.write(txt_content)
    
    print(f"生成 TXT 文件: float_array.txt")
    print(f"包含 {total_count} 个单精度浮点数")
    
    return all_numbers

# 生成 TXT 文件
generate_c_array_txt()
